import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import hengduanApi from '@views/Home/tool.ts'
import proxy from 'http-proxy-middleware'
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],

  resolve: {
    // https://cn.vitejs.dev/config/#resolve-alias
    alias: {
      // 设置路径
      '~': path.resolve(__dirname, './'),
      // 设置别名
      '@': path.resolve(__dirname, './src'),
    },
    // https://cn.vitejs.dev/config/#resolve-extensions
    extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
  },

  // vite 相关配置
  server: {
    port: 81,
    host: true,
    open: false,
    proxy: { 
      '/hen-api': {
        target: 'http://localhost:18080',
        changeOrigin: true,
        rewrite: (p) => p.replace(/^\/hen-api/, ''),
      },
    },
  },
})
